package com.dbuil.bleshoes.ui.activity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.blankj.utilcode.util.LogUtils;
import com.dbuil.bleshoes.R;

import butterknife.BindView;
import butterknife.OnClick;
import es.voghdev.pdfviewpager.library.RemotePDFViewPager;
import es.voghdev.pdfviewpager.library.adapter.PDFPagerAdapter;
import es.voghdev.pdfviewpager.library.remote.DownloadFile;

public class PdfViewActivity extends AppCompatActivity implements DownloadFile.Listener {
    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.tv_top_title)
    TextView tvTopTitle;
    @BindView(R.id.tv_top_right)
    TextView tvTopRight;
    @BindView(R.id.img_top_right)
    ImageView imgTopRight;


    String url = "http://www.cals.uidaho.edu/edComm/curricula/CustRel_curriculum/content/sample.pdf";
    private RemotePDFViewPager remotePDFViewPager;
    private PDFPagerAdapter adapter;



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        remotePDFViewPager = new RemotePDFViewPager(this, url, this);

    }

    @OnClick(R.id.img_back)
    public void onViewClicked() {
        this.finish();
    }

    @Override
    public void onSuccess(String url, String destinationPath) {
        adapter = new PDFPagerAdapter(this, "AdobeXMLFormsSamples.pdf");
        remotePDFViewPager.setAdapter(adapter);
        setContentView(remotePDFViewPager);
    }

    @Override
    public void onFailure(Exception e) {
        LogUtils.i("加载失败:"+e.getMessage());
    }

    @Override
    public void onProgressUpdate(int progress, int total) {
    //Always on UI Thread so feel free to update your views here\
        LogUtils.i("加载进度:"+progress);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

        if (adapter!=null) {
            adapter.close();
        }

    }
}
